Skip to contentSkip to conversation

Change in openvpn[master]: pkcs11_openssl: Silence a conversion warning

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Nov 6, 2025 – Nov 8, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1762436081000.I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email

to review the following change.

Change subject: pkcs11_openssl: Silence a conversion warning
......................................................................

pkcs11_openssl: Silence a conversion warning

The only caller of this function uses a constant for this parameter, so this is all quite safe. Add an ASSERT for good measure anyway to make the assumption explicit.

Change-Id I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995

---
M src/openvpn/pkcs11_openssl.c

1 file changed, 2 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1352/1

src/openvpn/pkcs11_openssl.c +2 -11
index f619b95..1d527db 100644
@@ -428,18 +428,12 @@
     return dn;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, size_t serial_len)
 {
     X509 *x509 = NULL;
     BIO *bio = NULL;
     int ret = 1;
-    int n;
 
     if ((x509 = pkcs11h_openssl_getX509(certificate)) == NULL)
     {
@@ -454,7 +448,8 @@
     }
 
     i2a_ASN1_INTEGER(bio, X509_get_serialNumber(x509));
-    n = BIO_read(bio, serial, serial_len - 1);
+    ASSERT(serial_len <= INT_MAX);
+    int n = BIO_read(bio, serial, (int)serial_len - 1);
 
     if (n < 0)
     {
@@ -474,8 +469,4 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995
Gerrit-Change-Number: 1352
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email )

Change subject: pkcs11_openssl: Silence a conversion warning
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995
Gerrit-Change-Number: 1352
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 06 Nov 2025 13:39:15 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 pkcs11_openssl: Silence a conversion warning

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

The only caller of this function uses a constant for this parameter, so this is all quite safe. Add an ASSERT for good measure anyway to make the assumption explicit.

Change-Id I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1352
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1352
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/pkcs11_openssl.c +2 -11
index f619b95..1d527db 100644
@@ -428,18 +428,12 @@
     return dn;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, size_t serial_len)
 {
     X509 *x509 = NULL;
     BIO *bio = NULL;
     int ret = 1;
-    int n;
 
     if ((x509 = pkcs11h_openssl_getX509(certificate)) == NULL)
     {
@@ -454,7 +448,8 @@
     }
 
     i2a_ASN1_INTEGER(bio, X509_get_serialNumber(x509));
-    n = BIO_read(bio, serial, serial_len - 1);
+    ASSERT(serial_len <= INT_MAX);
+    int n = BIO_read(bio, serial, (int)serial_len - 1);
 
     if (n < 0)
     {
@@ -474,8 +469,4 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: pkcs11_openssl: Silence a conversion warning

Makes sense. BB all green, one source file less to go.

Your patch has been applied to the master branch.

commit 4e9a10adb6eb938409dcdf6a1dfae44f12b29efc

Author: Frank Lichtenheld
Date:   Thu Nov 6 14:39:30 2025 +0100
     pkcs11_openssl: Silence a conversion warning

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1352
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34209.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: pkcs11_openssl: Silence a conversion warning
......................................................................

pkcs11_openssl: Silence a conversion warning

The only caller of this function uses a constant for this parameter, so this is all quite safe. Add an ASSERT for good measure anyway to make the assumption explicit.

Change-Id I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1352
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34209.html

---
M src/openvpn/pkcs11_openssl.c

1 file changed, 2 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1352/2

src/openvpn/pkcs11_openssl.c +2 -11
index f619b95..1d527db 100644
@@ -428,18 +428,12 @@
     return dn;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, size_t serial_len)
 {
     X509 *x509 = NULL;
     BIO *bio = NULL;
     int ret = 1;
-    int n;
 
     if ((x509 = pkcs11h_openssl_getX509(certificate)) == NULL)
     {
@@ -454,7 +448,8 @@
     }
 
     i2a_ASN1_INTEGER(bio, X509_get_serialNumber(x509));
-    n = BIO_read(bio, serial, serial_len - 1);
+    ASSERT(serial_len <= INT_MAX);
+    int n = BIO_read(bio, serial, (int)serial_len - 1);
 
     if (n < 0)
     {
@@ -474,8 +469,4 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995
Gerrit-Change-Number: 1352
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email )

Change subject: pkcs11_openssl: Silence a conversion warning
......................................................................

pkcs11_openssl: Silence a conversion warning

The only caller of this function uses a constant for this parameter, so this is all quite safe. Add an ASSERT for good measure anyway to make the assumption explicit.

Change-Id I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1352
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34209.html

---
M src/openvpn/pkcs11_openssl.c

1 file changed, 2 insertions(+), 11 deletions(-)
src/openvpn/pkcs11_openssl.c +2 -11
index f619b95..1d527db 100644
@@ -428,18 +428,12 @@
     return dn;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, size_t serial_len)
 {
     X509 *x509 = NULL;
     BIO *bio = NULL;
     int ret = 1;
-    int n;
 
     if ((x509 = pkcs11h_openssl_getX509(certificate)) == NULL)
     {
@@ -454,7 +448,8 @@
     }
 
     i2a_ASN1_INTEGER(bio, X509_get_serialNumber(x509));
-    n = BIO_read(bio, serial, serial_len - 1);
+    ASSERT(serial_len <= INT_MAX);
+    int n = BIO_read(bio, serial, (int)serial_len - 1);
 
     if (n < 0)
     {
@@ -474,8 +469,4 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1352?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995
Gerrit-Change-Number: 1352
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>